<p>Data directory contains:</p>
<ul>
  <li><code>document.db</code> - <a href="#root/_help_wX4HbRucYSDD">database</a>
  </li>
  <li><code>config.ini</code> - instance level settings like port on which the
    Trilium application runs</li>
  <li><code>backup</code> - contains automatically <a href="#root/_help_ODY7qQn5m2FT">backup</a> of
    documents</li>
  <li><code>log</code> - contains application log files</li>
</ul>
<h2>Location</h2>
<p>Easy way how to find out which data directory Trilium uses is to look
  at the "About Trilium Notes" dialog (from "Menu" in upper left corner):</p>
<p>
  <img src="Data directory_image.png">
</p>
<p>Here's how the location is decided:</p>
<p>Data directory is normally named <code>trilium-data</code> and it is stored
  in:</p>
<ul>
  <li><code>/home/[user]/.local/share</code> for Linux</li>
  <li><code>C:\Users\[user]\AppData\Roaming</code> for Windows Vista and up</li>
  <li><code>/Users/[user]/Library/Application Support</code> for Mac OS</li>
  <li>user's home is a fallback if some of the paths above don't exist</li>
  <li>user's home is also a default setup for [[docker|Docker server installation]]</li>
</ul>
<p>If you want to back up your Trilium data, just backup this single directory
  - it contains everything you need.</p>
<h3>Changing the location of data directory</h3>
<p>If you want to use some other location for the data directory than the
  default one, you may change it via TRILIUM_DATA_DIR environment variable
  to some other location:</p>
<h4>Linux</h4><pre><code class="language-text-x-trilium-auto">export TRILIUM_DATA_DIR=/home/myuser/data/my-trilium-data</code></pre>
<h4>Mac OS X</h4>
<p>You need to create a <code>.plist</code> file under <code>~/Library/LaunchAgents</code> to
  load it properly each login.</p>
<p>To load it manually, you need to use <code>launchctl setenv TRILIUM_DATA_DIR &lt;yourpath&gt;</code>
</p>
<p>Here is a pre-defined template, where you just need to add your path to:</p><pre><code class="language-text-x-trilium-auto">



    
        Label
        set.trilium.env
        RunAtLoad
        
        ProgramArguments
        
            launchctl
            setenv
            TRILIUM_DATA_DIR
            /Users/YourUserName/Library/Application Support/trilium-data
        
    
</code></pre>
<h3>Create a script to run with specific data directory</h3>
<p>An alternative to globally setting environment variable is to run only
  the Trilium Notes with this environment variable. This then allows for
  different setup styles like two <a href="#root/_help_wX4HbRucYSDD">database</a> instances
  or "portable" installation.</p>
<p>To do this in unix based systems simply run trilium like this:</p><pre><code class="language-text-x-trilium-auto">TRILIUM_DATA_DIR=/home/myuser/data/my-trilium-data trilium</code></pre>
<p>You can then save the above command as a shell script on your path for
  convenience.</p>
<h3>Fine-grained directory/path location</h3>
<p>It's possible to configure e.g. backup and log directories separately,
  with following environment variables:</p>
<ul>
  <li><code>TRILIUM_DOCUMENT_PATH</code>
  </li>
  <li><code>TRILIUM_BACKUP_DIR</code>
  </li>
  <li><code>TRILIUM_LOG_DIR</code>
  </li>
  <li><code>TRILIUM_ANONYMIZED_DB_DIR</code>
  </li>
  <li><code>TRILIUM_CONFIG_INI_PATH</code>
  </li>
</ul>
<p>If these are not set, default paths within the data directory will be
  used.</p>